package basic50.fortieth;

import java.util.Arrays;

public class Basic36 {
    public static void main(String[] args) {
       // 题目：有n个整数，使其前面各数顺序向后移m个位置，最后m个数变成最前面的m个数
        int n =11;
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = (int) (Math.random() *100);
        }
        System.out.println(Arrays.toString(a));
        int m =5;
        move(a,m);
        System.out.println(Arrays.toString(a));

    }

    private static void move(int[] a,int m) {
        reverse(a,0,a.length-1);
        reverse(a,0,m-1);
        reverse(a,m,a.length-1);
    }
    private static void reverse(int[] a, int start, int end) {
        while (start < end) {
            int temp = a[start];
            a[start] = a[end];
            a[end] = temp;
            start++;
            end--;
        }
    }
}
